package com.ktjy.ch05.service.impl;

import com.ktjy.ch05.entity.Right;
import com.ktjy.ch05.entity.RoleRight;
import com.ktjy.ch05.mapper.RoleRightMapper;
import com.ktjy.ch05.service.RightService;
import com.ktjy.ch05.service.RoleRightService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @return 13141
 * 2025/7/21
 * 11:23
 */
@Service("roleRightService")
public class RoleRightServiceImpl implements RoleRightService {
    @Resource
    private RoleRightMapper roleRightMapper;
    @Resource
    private RightService rightService;

    @Override
    public List<Right> getRoleRights(Long rfRoleId) {
        List<RoleRight> roleRightList = roleRightMapper.getRight(rfRoleId);
        List<Right> list = new ArrayList<>();
        for (RoleRight roleRight : roleRightList) {
            list.add(rightService.get(roleRight.getRfRightCode()));
        }
        return list;
    }
}
